import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

import '../../../../lib_basemodel/user/user.dart';
import 'doufeng_tacit_dialog_manager.dart';
import 'doufeng_tacit_model.dart';

class InvitingFromWidget extends StatefulWidget {
  User userFrom;
  User userTo;

  InvitingFromWidget({required this.userFrom, required this.userTo});

  @override
  State<InvitingFromWidget> createState() => _InvitingFromWidgetState();
}

class _InvitingFromWidgetState extends State<InvitingFromWidget> {
  @override
  void initState() {
    super.initState();
    context.read<DoufengTacitModel>().autoDismissFunc();
  }

  @override
  Widget build(BuildContext context) {
    return Consumer<DoufengTacitModel>(builder: (context, model, child) {
      return Container(
        padding: const EdgeInsets.symmetric(
          horizontal: 34,
        ),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            Row(
              children: [
                // AvatarImage(
                //     url: widget.userFrom.avatar, width: 52, height: 52, borderRadius: 26),
                const SizedBox(
                  width: 10,
                ),
                Expanded(
                  child: Text(
                    "${widget.userFrom.nickname}开启了默契测试，一起来测测默契值吧",
                    style: const TextStyle(
                      fontSize: 13,
                      fontWeight: FontWeight.w500,
                      color: Colors.white,
                    ),
                  ),
                )
              ],
            ),
            const SizedBox(
              height: 53,
            ),
            CupertinoButton(
              minSize: 0,
              padding: EdgeInsets.zero,
              onPressed: () {
                Navigator.pop(context);
                DoufengTacitDialogManager.showWaitingStartDialog(context);
              },
              child: Text(
                "等待 ${widget.userTo.nickname} 接受邀请 ${model.autoDismissSec}s",
                style: TextStyle(
                  fontSize: 13,
                  fontWeight: FontWeight.w500,
                  color: Colors.white,
                ),
              ),
            )
          ],
        ),
      );
    });
  }
}
